package com.lanxiao.cloud.common.web.service.impl;

import cn.hutool.core.convert.ConverterRegistry;
import com.lanxiao.cloud.common.web.SpringUtil;
import com.lanxiao.cloud.common.web.invalid.Log;
import com.lanxiao.cloud.common.web.service.IContentParse;
import com.lanxiao.cloud.common.web.service.ILog;
import java.util.Objects;
import org.springframework.stereotype.Service;

/**
 * @author ：qiaoliang
 * @date ：2021-10-19
 */
@Service
public class DefaultContentParse implements IContentParse {

  @Override
  public Object getResult(Object id, Log logs) {
    if (Objects.isNull(id)) {
      return null;
    }
    final ILog bean = SpringUtil.getBean(logs.serviceClass());
    return bean.selectById(ConverterRegistry.getInstance().convert(logs.idType(), id));
  }

}
